<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCompanyInfoTable extends Migration{
    /**
     * Run the migrations.
     * @return void
     */
    public function up(){
        /*  企业用户表 company_users */
        Schema::create('company_users',function (Blueprint $table ){
            $table->engine='MyISAM';
            $table->increments('uid')->unsigned()->comment('自增长主键');
            $table->string('username',60)->unique('username')->default('')->comment('用户名');
            $table->string('password',60)->default('')->comment('密码');
            $table->string('mobile',11)->default('')->comment('手机号码');
            $table->string('contacts',60)->default('')->comment('联系人');
            $table->string('company_name',60)->default('')->comment('公司名称');
            $table->string('email',60)->default('')->comment('邮箱');
            $table->string('regip')->default('')->comment('注册ip');
            $table->string('phone',20)->default('')->comment('固定电话');
            $table->string('last_login_ip')->default('')->comment('最后登录ip');
            $table->string('remember_token',100)->nullable()->comment('记住登录密码');
            $table->string('api_token',60)->nullable()->comment('手机api验证字段');
            $table->timestamp('regtime')->nullable()->comment('注册时间');
            $table->timestamp('updatetime')->index('updatetime')->nullable()->comment('更新时间');
            $table->timestamp('last_login_time')->nullable()->comment('最后登录时间');
            $table->timestamp('last_service_time')->nullable()->comment('最后通话时间');
            $table->timestamp('surpris_visit_time')->nullable()->comment('突访时间');
            $table->timestamp('viptime')->index('viptime')->nullable()->comment('会员到期时间');
            $table->mediumInteger('vip_resume_number')->unsigned()->default(0)->comment('会员期内简历数');
            $table->mediumInteger('vip_integral')->unsigned()->default(0)->comment('会员期内积分');
            $table->mediumInteger('vip_post_number')->unsigned()->default(0)->comment('会员期内职位数');
            $table->mediumInteger('resume_number')->unsigned()->default(0)->comment('非会员简历数');
            $table->mediumInteger('integral')->unsigned()->default(0)->comment('非会员积分');
            $table->string('device_token',60)->nullable()->comment('设备标识(Api)');
            $table->tinyInteger('email_id')->unsigned()->default(0)->comment('验证邮箱是不是绑定');
            $table->tinyInteger('mobile_id')->unsigned()->default(0)->comment('验证手机是不是绑定');
            $table->string('qqopenid',64)->unique('qqopenid')->nullable()->comment('验证qq是不是绑定');
            $table->string('wechatopenid',64)->unique('wechatopenid')->nullable()->comment('验证微信是不是绑定');
            $table->string('wechatmpopenid',64)->unique('wechatmpopenid')->nullable()->comment('微信公众平台');
            $table->string('wechatunionid',64)->unique('wechatunionid')->nullable()->comment('微信unionid');
            $table->integer('crm_uid')->default(0)->comment('客服ID');
        });

        /*  企业基本资料表 company_basic */
        Schema::create('company_basic',function (Blueprint $table ) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自增长主键');
            $table->integer('uid')->unique('uid')->default(0)->comment('所属用户uid');
            $table->string('company_name',100)->default('')->comment('公司名称');
            $table->string('brands',100)->default('')->comment('公司品牌');
            $table->smallInteger('industry')->unsigned()->default(0)->comment('所属行业');
            $table->tinyInteger('comkind')->unsigned()->default(0)->comment('公司性质');
            $table->date('established')->default('0000-00-00')->comment('成立年份');
            $table->string('employee_num',60)->default('')->comment('员工数量');
            $table->string('temptation',255)->default('')->comment('公司诱惑');
            $table->text('profile')->default('')->comment('公司简介');
            $table->string('contacts',60)->default('')->comment('联系人');
            $table->string('mobile', 11)->default('')->default('')->comment('手机号码');
            $table->string('phone',20)->default('')->comment('座机号码');
            $table->string('fax',20)->default('')->comment('传真号码');
            $table->string('email',60)->default('')->comment('电子邮件');
            $table->string('qq',20)->default('')->comment('qq');
            $table->string('website',60)->default('')->comment('公司网站');
            $table->mediumInteger('region')->unsigned()->default(0)->comment('地区');
            $table->string('address',200)->default('')->comment('详细地址');
            $table->string('lines',200)->default('')->comment('乘车路线');
            $table->string('longitude',20)->default('')->comment('坐标经度');
            $table->string('latitude',20)->default('')->comment('坐标纬度');
            $table->string('coordinate_address',200)->default('')->comment('坐标地址');
            $table->string('logo',30)->default('')->comment('公司logo');
            $table->integer('micro_like')->unsigned()->default(0)->comment('点赞数量');
            $table->integer('cert_status')->unsigned()->index('cert_status')->default(0)->comment('企业认证状态(0未认证1通过认证)');
            $table->timestamp('addtime')->nullable()->comment('添加时间');
            $table->timestamp('updatetime')->index('regtime')->nullable()->comment('更新时间');
        });
        /*  企业职位信息表 company_job */
        Schema::create('company_job',function (Blueprint $table ) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自增主键');
            $table->integer('com_id')->unsigned()->index('com_id')->default(0)->comment('所属企业id');
            $table->integer('uid')->unsigned()->index('uid')->default(0)->comment('所属用户uid');
            $table->string('job_title',60)->default('')->comment('职位名称');
            $table->mediumInteger('job_category1')->unsigned()->default(0)->comment('岗位类别1');
            $table->mediumInteger('job_category2')->unsigned()->default(0)->comment('岗位类别2');
            $table->mediumInteger('job_category3')->unsigned()->default(0)->comment('岗位类别3');
            $table->mediumInteger('job_category4')->unsigned()->default(0)->comment('岗位类别4');
            $table->mediumInteger('job_category5')->unsigned()->default(0)->comment('岗位类别5');
            $table->smallInteger('industry')->unsigned()->default(0)->comment('所属行业');
            $table->mediumInteger('location1')->unsigned()->default(0)->comment('工作地点1');
            $table->mediumInteger('location2')->unsigned()->default(0)->comment('工作地点2');
            $table->mediumInteger('location3')->unsigned()->default(0)->comment('工作地点3');
            $table->mediumInteger('location4')->unsigned()->default(0)->comment('工作地点4');
            $table->mediumInteger('location5')->unsigned()->default(0)->comment('工作地点5');
            $table->tinyInteger('department')->unsigned()->default(0)->comment('招聘部门');
            $table->tinyInteger('recruiting_num')->unsigned()->comment('招聘人数');
            $table->string('salary_above', 12)->default('')->comment('薪资待遇>');
            $table->string('salary_below', 12)->default('')->comment('薪资待遇<');
            $table->text('description')->default('')->comment('描述');
            $table->tinyInteger('education')->unsigned()->default(0)->comment('学历');
            $table->tinyInteger('work_year')->unsigned()->default(0)->comment('工作经验');
            $table->tinyInteger('age_above')->unsigned()->comment('年龄要求>');
            $table->tinyInteger('age_below')->unsigned()->comment('年龄要求<');
            $table->tinyInteger('gender')->unsigned()->comment('性别要求');
            $table->tinyInteger('language')->unsigned()->comment('语言要求');
            $table->string('welfare',200)->default('')->comment('福利');
            $table->tinyInteger('contact_info')->unsigned()->comment('是否独立联系方式');
            $table->tinyInteger('job_status')->unsigned()->default(0)->comment('职位状态(0未审核1审核通过2代表屏蔽4代表删除)');
            $table->tinyInteger('part_status')->unsigned()->default(0)->comment('兼职状态(1全职 2实习 3兼职 4临时)');
            $table->tinyInteger('pageviews')->unsigned()->default(0)->comment('浏览量');
            $table->timestamp('addtime')->nullable()->comment('添加时间');
            $table->timestamp('updatetime')->nullable()->comment('更新时间');
            $table->timestamp('urgent')->nullable()->comment('急招，紧急');
            $table->index(['urgent', 'updatetime']);
            $table->index(['updatetime', 'id']);
        });

        /*  企业独立联系方式表 company_contact */
        Schema::create('company_contact',function (Blueprint $table ) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自增主键');
            $table->integer('job_id')->unique('job_id')->default(0)->comment('所属招聘信息id');
            $table->integer('uid')->index('uid')->default(0)->comment('所属用户uid');
            $table->string('contacts', 60)->default('')->comment('联系人');
            $table->string('mobile', 11)->default('')->comment('手机号码');
            $table->string('phone', 20)->default('')->comment('固定电话');
            $table->string('fax', 20)->default('')->comment('传真');
            $table->string('email', 60)->default('')->comment('电子邮件');
            $table->timestamp('addtime')->nullable()->comment('添加时间');
            $table->timestamp('updatetime')->index('regtime')->nullable()->comment('更新时间');
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down(){
        Schema::drop('company_users');
        Schema::drop('company_info');
        Schema::drop('company_job');
        Schema::drop('company_contact');
    }
}
